<!--
 * @Author: your name
 * @Date: 2022-03-08 11:12:40
 * @LastEditTime: 2022-05-11 23:18:38
 * @LastEditors: JPeng 872639397@qq.com
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\字符串number排序.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log('3' > '30' ? '3' : '30');

        const NumberSort = function (nums) {
            if (nums.length === 0) return [];
            if (nums.length === 1) return [nums[0]];
            if (nums.length === 2) return nums[0] > nums[1] ? [nums[1], nums[0]] : [nums[0], nums[1]];
            let left = [], right = [];
            let mid = parseInt(nums.length / 2);
            for (let i = 0; i < nums.length; i++) {
                if (i === mid) continue;
                if (nums[i] <= nums[mid]) {
                    left.push(nums[i]);
                } else {
                    right.push(nums[i]);
                }
            }
            return NumberSort(left).concat([nums[mid]]).concat(NumberSort(right));
        }
        console.log(NumberSort([11,0,9,0,0]));

        let arr = [];
        //arr[-1] = 2;
        arr[1] = 3;
        console.log(arr);

        let arr2 = [2,6,10];
        arr2.splice(1,0,7);
        console.log(arr2);
    </script>
</body>

</html>